#ifndef CLISTITEM_H
#define CLISTITEM_H
#include <QObject>
#include "cobject.h"
namespace cooking {

class CListItem : public CObject
{
    Q_OBJECT

    Q_ENUMS(ItemType)
    Q_PROPERTY(int listId READ listId WRITE setListId NOTIFY listIdChanged)
    Q_PROPERTY(int itemId READ itemId WRITE setItemId NOTIFY itemIdChanged)
    Q_PROPERTY(ItemType itemType READ itemType WRITE setItemType NOTIFY itemTypeChanged)
    /**
     * Name is readonly because it is gotten from other table.
     */
    Q_PROPERTY(QString name READ name NOTIFY nameChanged)
    /**
     * quantity is readonly because it is calculated.
     */
    Q_PROPERTY(double quantity READ quantity NOTIFY quantityChanged)
    Q_PROPERTY(double purchasedQuantity READ purchasedQuantity WRITE setPurchasedQuantity NOTIFY purchasedQuantityChanged)
    Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
public:
    enum ItemType {
        ECustomItem,
        EIngredient
    };

    explicit CListItem(QObject* parent = 0);
    int listId();
    void setListId(int listId);

    int itemId();
    void setItemId(int itemId);

    ItemType itemType();
    void setItemType(ItemType itemType);

    QString name();
    void setName(QString name);

    double quantity();
    void setQuantity(double quantity);

    double purchasedQuantity();
    void setPurchasedQuantity(double quantity);

    QString description();
    void setDescription(QString description);

signals:
    void listIdChanged();
    void itemIdChanged();
    void itemTypeChanged();
    void nameChanged();
    void quantityChanged();
    void purchasedQuantityChanged();
    void descriptionChanged();

private:
    int m_list_id;
    int m_item_id;
    ItemType m_item_type;
    QString m_name;
    double m_quantity;
    double m_purchased_quantity;
    QString m_description;
};
} // namespace cooking
#endif // CLISTITEM_H
